//
//  TodayTableViewHeaderView.swift
//  appstore
//
//  Created by llbt-sk on 2019/11/5.
//  Copyright © 2019 Roy. All rights reserved.
//

import UIKit

class TodayTableViewHeaderView: UIView {
    
    lazy var dateLabel = UILabel()
    lazy var todayLabel = UILabel()
    lazy var iconItem = UIButton()
    
    var iconItemClick:(() -> (Void))?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.initView()
    }
    
    func initView() -> Void {
        
        dateLabel.text = "TUESDAY, JULY 10"
        dateLabel.textColor = .gray
        dateLabel.font = UIFont.boldSystemFont(ofSize: 13)
        self.addSubview(dateLabel)
        dateLabel.snp.makeConstraints { (make) in
            make.left.equalTo(20.0)
            make.top.equalTo(30.0)
            make.width.equalTo(200.0)
            make.height.equalTo(15.0)
        }
        
        todayLabel.text = "Today"
        todayLabel.font = UIFont.boldSystemFont(ofSize: 34)
        self.addSubview(todayLabel)
        todayLabel.snp.makeConstraints { (make) in
            make.left.equalTo(20.0)
            make.top.equalTo(48.0)
            make.width.equalTo(200.0)
            make.height.equalTo(40.0)
        }
        
        iconItem = UIButton(type: .custom)
        iconItem.setImage(UIImage(named: "demo_icon"), for: .normal)
        iconItem.layer.cornerRadius = 22.0
        iconItem.layer.masksToBounds = true
        iconItem.addTarget(self, action: #selector(iconItemClickAction), for: .touchUpInside)
        self.addSubview(iconItem)
        iconItem.snp.makeConstraints { (make) in
            make.right.equalTo(-20.0)
            make.top.equalTo(46.0)
            make.width.height.equalTo(44.0)
        }
        
    }
    
    // private
    @objc func iconItemClickAction() -> Void {
        iconItemClick!()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
